package com.yrline.pay.web.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.yrline.pay.proxy.PayInvoke;
import com.yrline.pay.proxy.request.CommonRequest;
import com.yrline.pay.proxy.request.FreezeRequest;
import com.yrline.pay.proxy.request.LoginIpsRequest;
import com.yrline.pay.proxy.request.ProjectRegRequest;
import com.yrline.pay.proxy.request.QueryParam;
import com.yrline.pay.proxy.request.RechargeRequest;
import com.yrline.pay.proxy.response.QueryResponse;
import com.yrline.pay.services.OperatorServices;
import com.yrline.pay.services.ProjectServices;
import com.yrline.pay.services.RechargeServices;
import com.yrline.pay.services.UserServices;
import com.yrline.pay.services.vo.InvestVo;
import com.yrline.pay.services.vo.ProjectVo;
import com.yrline.pay.services.vo.UserVo;
import com.yrline.pay.web.PayUtil;
import com.yrline.pay.web.ResponseVo;

@RestController
@RequestMapping(value = "/q")
public class QueryController {
	@Autowired
	PayInvoke payInvoke;
	@Autowired
	PayUtil payUtil;
	@Autowired
	UserServices userSerivces;
	@Autowired
	RechargeServices rechargeServices;
	@Autowired
	ProjectServices projectServices;
	@Autowired
	OperatorServices operatorServices;
	@RequestMapping(value = "/users")
	public List<UserVo> queryUsers(){
	   return userSerivces.selectUser(null);	
	}
	@RequestMapping(value = "/recharges")
	public List<RechargeRequest> queryRecharges(){
	   return rechargeServices.selectAll();	
	}
	@RequestMapping(value = "/project")
	public List<ProjectVo> queryProjects(){
	   return projectServices.selectAll();	
	}
	@RequestMapping(value = "/ipsbalance")
	public ResponseVo<QueryResponse> queryUserIpsBalance(@RequestParam String ipsAcctNo){
		QueryParam p = new QueryParam();
		p.setIpsAcctNo(ipsAcctNo);
		p.setQueryType("03");
		CommonRequest request = payUtil.getDefaultRequest(p, "query.commonQuery");
		QueryResponse response=(QueryResponse)	payInvoke.invoke(request, QueryResponse.class);
		return ResponseVo.getSuccessResponse(response);
	}
	@RequestMapping(value = "/inverstList")
	public List<InvestVo> inverstList(@RequestParam String projectNo){
		
		return operatorServices.inverstList(projectNo);
	}
	
}
